package com.jinmdz.app.api.api.controller;

import com.jinmdz.app.api.api.model.coldstorage.ColdStorageInData;
import com.jinmdz.app.api.api.model.common.QrCodeData;
import com.jinmdz.app.api.global.config.swagger.ApiResponseObject;
import com.jinmdz.app.api.global.config.swagger.ApiResponseProperty;
import com.jinmdz.app.dao.model.coldStorageEquipment.ColdStorageEquipmentView;
import com.jinmdz.app.dao.model.coldstorage.ColdStorageView;
import com.jinmdz.app.api.api.model.common.BusinessCodeData;
import com.jinmdz.app.api.api.service.ColdStorageService;
import com.jinmdz.app.api.base.BaseController;
import com.jinmdz.fmis.core.base.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * 冷藏PDA相关接口
 *
 * @author Wangshengtao
 * @date 2020-08-24 08:54
 */
@Api(description = "冷藏PDA相关接口")
@RestController
@RequestMapping("/api/cold-storage")
public class ColdStorageController extends BaseController {

    @Resource
    private ColdStorageService coldStorageService;


    /**
     * 根据 遗体编码 加载冷藏信息
     *
     * @param data 业务编码数据
     * @return ColdStorageView(逝者姓名 ， 家属姓名 ， 家属电话 ， 流程状态 ）
     * @author Wangshengtao
     * @date 2020-08-24 08:54
     */
    @ApiOperation(value = "遗体扫码冷藏信息加载接口", notes = "遗体扫码冷藏信息加载接口")
    @PostMapping("/load-cold-storage-with-business-code")
    public BaseResult<ColdStorageView> loadColdStorageInfoWithBusinessCode(@RequestBody BusinessCodeData data) {
        return resultHandler(userItem -> coldStorageService.loadColdStorageWithBusinessCode(data));
    }

    /**
     * 根据 冷柜设备编码 加载冷柜信息
     *
     * @param qrCodeData 设备编码
     * @return ColdStorageView
     * @author Wangshengtao
     * @date 2020-08-24 08:54
     */
    @ApiOperation(value = "冷柜扫码冷藏柜信息加载接口", notes = "冷柜扫码冷藏柜信息加载接口")
    @PostMapping("/load-cold-storage-equipment-with-equipment-code")

    @ApiImplicitParams({
            //@ApiImplicitParam(name = "id",value = "用户id",paramType = "path",dataType = "MAP_>"),
            @ApiImplicitParam(name = "qrCodeData",value="二维码",paramType = "query",dataType = "string")
    })
    @ApiResponseObject(properties = {
            @ApiResponseProperty(name = "process_state_text",description = "已入仓",type = "string"),
            @ApiResponseProperty(name = "disable_state",description = "禁用状态",type = "int"),
            @ApiResponseProperty(name = "equipment_code",description = "设备编码",type = "string")
    })
    public BaseResult<HashMap<String,Object>> loadColdStorageEquipmentByEquipmentCode(@RequestBody HashMap<String,Object> qrCodeData) {
        return resultHandler(userItem -> coldStorageService.loadColdStorageEquipmentWithEquipmentCode(qrCodeData));
    }

    /**
     * 入藏
     *
     * @param data 业务编码
     * @return
     * @author Wangshengtao
     * @date 2020-08-24 16:54
     */
    @ApiOperation(value = "入藏", notes = "入藏")
    @PostMapping("/save-dead-to-equipment")
    public BaseResult saveDeadToEquipment(@RequestBody ColdStorageInData data) {
        return resultHandler(userItem -> coldStorageService.saveDeadToEquipment(userItem,data));
    }


}
